package com.cy.platform;

import android.graphics.Paint;
import android.support.v7.app.AlertDialog;
import android.support.v7.app.AppCompatActivity;
import android.os.Bundle;
import android.support.v7.widget.LinearLayoutManager;
import android.support.v7.widget.RecyclerView;
import android.text.TextUtils;
import android.util.Log;
import android.view.Display;
import android.view.View;
import android.widget.LinearLayout;
import android.widget.TextView;
import android.widget.Toast;

import com.google.gson.Gson;
import com.lzy.okgo.OkGo;
import com.lzy.okgo.callback.StringCallback;
import com.lzy.okgo.model.Response;

import java.io.IOException;
import java.text.SimpleDateFormat;
import java.util.ArrayList;
import java.util.Date;
import java.util.HashMap;
import java.util.List;
import java.util.Locale;
import java.util.Map;
import java.util.Random;
import java.util.Timer;
import java.util.TimerTask;

public class MainActivity extends AppCompatActivity {
    private RecyclerView rvList;
    private LineAdapter lineAdapter;
    private GradientRoundProgress gradientRoundProgress1, gradientRoundProgress2,
            gradientRoundProgress3, gradientRoundProgress4;
    private LineView lineView;
    private BarChartView hvChart;
    private LinearLayout llRefresh, llDate, llCapacity;

    private TextView tvDate, tvCapacity, tvYield1, tvYield2, tvYield3, tvYield4, tvShipmentRate1, tvShipmentRate2;

    private TextView tvEquipment1, tvEquipment1Number, tvEquipment1Model, tvEquipment1Size, tvEquipment1Demand,
            tvEquipment1Shipped, tvEquipment1Delivered, tvEquipment1Productiond, tvEquipment1DeliveryTime;

    private TextView tvEquipment2, tvEquipment2Number, tvEquipment2Model, tvEquipment2Size, tvEquipment2Demand,
            tvEquipment2Shipped, tvEquipment2Delivered, tvEquipment2Productiond, tvEquipment2DeliveryTime;

    private TextView tvEquipment3, tvEquipment3Number, tvEquipment3Model, tvEquipment3Size, tvEquipment3Demand,
            tvEquipment3Shipped, tvEquipment3Delivered, tvEquipment3Productiond, tvEquipment3DeliveryTime;

    private TextView tvEquipment4, tvEquipment4Number, tvEquipment4Model, tvEquipment4Size, tvEquipment4Demand,
            tvEquipment4Shipped, tvEquipment4Delivered, tvEquipment4Productiond, tvEquipment4DeliveryTime;

    private TextView tvEquipment5, tvEquipment5Number, tvEquipment5Model, tvEquipment5Size, tvEquipment5Demand,
            tvEquipment5Shipped, tvEquipment5Delivered, tvEquipment5Productiond, tvEquipment5DeliveryTime;

    private TextView tvEquipment6, tvEquipment6Number, tvEquipment6Model, tvEquipment6Size, tvEquipment6Demand,
            tvEquipment6Shipped, tvEquipment6Delivered, tvEquipment6Productiond, tvEquipment6DeliveryTime;

    private SimpleDateFormat sdf = new SimpleDateFormat("yyyy-MM-dd", Locale.getDefault());
    private String selectDate = sdf.format(new Date());
    private String selectNum = "10000";
    // 间隔时间
    public static final long TIME_PERIOD = 30000;
    private void initTimer(){
        Timer timer = new Timer();
        TimerTask task = new TimerTask() {
            @Override
            public void run(){
                loadOnlineData();
            }
        };
        timer.schedule(task,TIME_PERIOD,TIME_PERIOD);
    }

    @Override
    protected void onCreate(Bundle savedInstanceState) {
        super.onCreate(savedInstanceState);
        Utils.setDensity(getApplication(), this);
        setContentView(R.layout.activity_main);
        llRefresh = findViewById(R.id.ll_refresh);
        llRefresh.setOnClickListener(new View.OnClickListener() {
            @Override
            public void onClick(View v) {
                loadOnlineData();
            }
        });
        // 日期
        initDateDialog();
        llDate = findViewById(R.id.ll_date);
        tvDate = findViewById(R.id.tv_date);
        llDate.setOnClickListener(new View.OnClickListener() {
            @Override
            public void onClick(View v) {
                String date = tvDate.getText().toString().trim();
                if (TextUtils.isEmpty(date)) {
                    commonDatePicker.show(sdf.format(new Date()));
                } else {
                    commonDatePicker.show(date);
                }
            }
        });
        // 产能
        initCapacityDialog();
        llCapacity = findViewById(R.id.ll_capacity);
        tvCapacity = findViewById(R.id.tv_capacity);
        llCapacity.setOnClickListener(new View.OnClickListener() {
            @Override
            public void onClick(View v) {
                capacityDialog.show();
            }
        });

        // 良率
        tvYield1 = findViewById(R.id.tv_yield_1);
        tvYield2 = findViewById(R.id.tv_yield_2);
        tvYield3 = findViewById(R.id.tv_yield_3);
        tvYield4 = findViewById(R.id.tv_yield_4);

        // 出货率 1
        tvShipmentRate1 = findViewById(R.id.tv_shipment_rate_1);
        // 打印设备1
        tvEquipment1 = findViewById(R.id.tv_equipment_1);
        // 编号
        tvEquipment1Number = findViewById(R.id.tv_equipment_1_number);
        //型号
        tvEquipment1Model = findViewById(R.id.tv_equipment_1_model);
        // 尺寸
        tvEquipment1Size = findViewById(R.id.tv_equipment_1_size);
        // 需求
        tvEquipment1Demand = findViewById(R.id.tv_equipment_1_demand);
        // 待发货
        tvEquipment1Shipped = findViewById(R.id.tv_equipment_1_shipped);
        // 已交付
        tvEquipment1Delivered = findViewById(R.id.tv_equipment_1_delivered);
        // 需生产
        tvEquipment1Productiond = findViewById(R.id.tv_equipment_1_productiond);
        // 交期
        tvEquipment1DeliveryTime = findViewById(R.id.tv_equipment_1_delivery_time);

        // 打印设备2
        tvEquipment2 = findViewById(R.id.tv_equipment_2);
        // 编号
        tvEquipment2Number = findViewById(R.id.tv_equipment_2_number);
        //型号
        tvEquipment2Model = findViewById(R.id.tv_equipment_2_model);
        // 尺寸
        tvEquipment2Size = findViewById(R.id.tv_equipment_2_size);
        // 需求
        tvEquipment2Demand = findViewById(R.id.tv_equipment_2_demand);
        // 待发货
        tvEquipment2Shipped = findViewById(R.id.tv_equipment_2_shipped);
        // 已交付
        tvEquipment2Delivered = findViewById(R.id.tv_equipment_2_delivered);
        // 需生产
        tvEquipment2Productiond = findViewById(R.id.tv_equipment_2_productiond);
        // 交期
        tvEquipment2DeliveryTime = findViewById(R.id.tv_equipment_2_delivery_time);

        // 贴合设备
        tvEquipment3 = findViewById(R.id.tv_equipment_3);
        // 编号
        tvEquipment3Number = findViewById(R.id.tv_equipment_3_number);
        //型号
        tvEquipment3Model = findViewById(R.id.tv_equipment_3_model);
        // 尺寸
        tvEquipment3Size = findViewById(R.id.tv_equipment_3_size);
        // 需求
        tvEquipment3Demand = findViewById(R.id.tv_equipment_3_demand);
        // 待发货
        tvEquipment3Shipped = findViewById(R.id.tv_equipment_3_shipped);
        // 已交付
        tvEquipment3Delivered = findViewById(R.id.tv_equipment_3_delivered);
        // 需生产
        tvEquipment3Productiond = findViewById(R.id.tv_equipment_3_productiond);
        // 交期
        tvEquipment3DeliveryTime = findViewById(R.id.tv_equipment_3_delivery_time);

        // 出货率 2
        tvShipmentRate2 = findViewById(R.id.tv_shipment_rate_2);

        // 焊接设备1
        tvEquipment4 = findViewById(R.id.tv_equipment_4);
        // 编号
        tvEquipment4Number = findViewById(R.id.tv_equipment_4_number);
        //型号
        tvEquipment4Model = findViewById(R.id.tv_equipment_4_model);
        // 尺寸
        tvEquipment4Size = findViewById(R.id.tv_equipment_4_size);
        // 需求
        tvEquipment4Demand = findViewById(R.id.tv_equipment_4_demand);
        // 待发货
        tvEquipment4Shipped = findViewById(R.id.tv_equipment_4_shipped);
        // 已交付
        tvEquipment4Delivered = findViewById(R.id.tv_equipment_4_delivered);
        // 需生产
        tvEquipment4Productiond = findViewById(R.id.tv_equipment_4_productiond);
        // 交期
        tvEquipment4DeliveryTime = findViewById(R.id.tv_equipment_4_delivery_time);

        // 焊接设备2
        tvEquipment5 = findViewById(R.id.tv_equipment_5);
        // 编号
        tvEquipment5Number = findViewById(R.id.tv_equipment_5_number);
        //型号
        tvEquipment5Model = findViewById(R.id.tv_equipment_5_model);
        // 尺寸
        tvEquipment5Size = findViewById(R.id.tv_equipment_5_size);
        // 需求
        tvEquipment5Demand = findViewById(R.id.tv_equipment_5_demand);
        // 待发货
        tvEquipment5Shipped = findViewById(R.id.tv_equipment_5_shipped);
        // 已交付
        tvEquipment5Delivered = findViewById(R.id.tv_equipment_5_delivered);
        // 需生产
        tvEquipment5Productiond = findViewById(R.id.tv_equipment_5_productiond);
        // 交期
        tvEquipment5DeliveryTime = findViewById(R.id.tv_equipment_5_delivery_time);

        // 包装车间
        tvEquipment6 = findViewById(R.id.tv_equipment_6);
        // 编号
        tvEquipment6Number = findViewById(R.id.tv_equipment_6_number);
        //型号
        tvEquipment6Model = findViewById(R.id.tv_equipment_6_model);
        // 尺寸
        tvEquipment6Size = findViewById(R.id.tv_equipment_6_size);
        // 需求
        tvEquipment6Demand = findViewById(R.id.tv_equipment_6_demand);
        // 待发货
        tvEquipment6Shipped = findViewById(R.id.tv_equipment_6_shipped);
        // 已交付
        tvEquipment6Delivered = findViewById(R.id.tv_equipment_6_delivered);
        // 需生产
        tvEquipment6Productiond = findViewById(R.id.tv_equipment_6_productiond);
        // 交期
        tvEquipment6DeliveryTime = findViewById(R.id.tv_equipment_6_delivery_time);
        // 产线列表
        rvList = findViewById(R.id.rv_list);
        rvList.setLayoutManager(new LinearLayoutManager(this));
        lineAdapter = new LineAdapter();
        rvList.setAdapter(lineAdapter);
        // 各种利用率
        gradientRoundProgress1 = findViewById(R.id.grp_1);
        gradientRoundProgress2 = findViewById(R.id.grp_2);
        gradientRoundProgress3 = findViewById(R.id.grp_3);
        gradientRoundProgress4 = findViewById(R.id.grp_4);
        //产量生产情况
        lineView = findViewById(R.id.line_view);
        //不良累计发生次数
        hvChart = findViewById(R.id.hv_chart);
        loadOnlineData();
        initTimer();
    }


    private int getMaxValue(List<Integer> datas) {
        int max = 0;
        if (datas == null) return max;
        for (int i = 0; i < datas.size(); i++) {
            int temp = datas.get(i);
            if (i == 0) {
                max = temp;
                continue;
            }
            if (temp > max) {
                max = temp;
            }
        }
        return max;
    }

    private int getMinValue(List<Integer> datas) {
        int min = 0;
        if (datas == null) return min;
        for (int i = 0; i < datas.size(); i++) {
            int temp = datas.get(i);
            if (i == 0) {
                min = temp;
                continue;
            }
            if (temp < min) {
                min = temp;
            }
        }
        return min;
    }



    private void showToast(String toast) {
        Toast.makeText(this, toast, Toast.LENGTH_SHORT).show();
    }

    // 日期选择器
    private CommonDatePicker commonDatePicker;
    private CapacityDialog capacityDialog;

    private void initDateDialog() {
        commonDatePicker = new CommonDatePicker(this, new CommonDatePicker.ResultHandler() {
            @Override
            public void handle(String time) { // 回调接口，获得选中的时间
                tvDate.setText(time);
                MainActivity.this.selectDate = time;
                loadOnlineData();
            }
        }, Constants.DATE_START_TIME, Constants.DATE_END_TIME); // 初始化日期格式请用：yyyy-MM-dd HH:mm，否则不能正常运行
    }

    private void initCapacityDialog() {
        List<String> sourceList = new ArrayList<>();
        for (int i = 0; i < 10; i++) {
            sourceList.add(String.valueOf(1000 * (i + 1)));
        }
        capacityDialog = new CapacityDialog(this, new CapacityDialog.ResultHandler() {
            @Override
            public void handle(String capacity) {
                tvCapacity.setText(capacity + "套");
                MainActivity.this.selectNum = capacity;
                loadOnlineData();
            }
        }, sourceList);
    }
    /**
     * 调用数据
     */
    private void loadOnlineData() {
        final Map<String, String> params = new HashMap<>();
        // 选择的时间
        params.put("selectDate", selectDate);
        // 选择的套数
        params.put("selectNum", selectNum);
        OkGo.<String>get("http://www.baidu.com").params(params).tag(this).execute(new StringCallback() {
            @Override
            public void onSuccess(Response<String> response) {
                // 解析数据
                showToast("解析数据吧");
//                String json = response.body();
//                CYPlatformBean cyPlatformBean = new Gson().fromJson(json,CYPlatformBean.class);
                // 模拟数据
                CYPlatformBean cyPlatformBean = allInitDate();
                parseBean(cyPlatformBean);
            }

            @Override
            public void onError(Response<String> response) {
                super.onError(response);
                showToast("网络请求异常");

            }
        });
    }

    private void parseBean(CYPlatformBean cyPlatformBean){

        tvYield1.setText(cyPlatformBean.getYield1());
        tvYield2.setText(cyPlatformBean.getYield2());
        tvYield3.setText(cyPlatformBean.getYield3());
        tvYield4.setText(cyPlatformBean.getYield4());

        tvShipmentRate1.setText(cyPlatformBean.getShipmentRate1());

        tvEquipment1.setText(cyPlatformBean.getEquipment1());
        tvEquipment1Number.setText(cyPlatformBean.getEquipment1Number());
        tvEquipment1Model.setText(cyPlatformBean.getEquipment1Model());
        tvEquipment1Size.setText(cyPlatformBean.getEquipment1Size());
        tvEquipment1Demand.setText(cyPlatformBean.getEquipment1Demand());
        tvEquipment1Shipped.setText(cyPlatformBean.getEquipment1Shipped());
        tvEquipment1Delivered.setText(cyPlatformBean.getEquipment1Delivered());
        tvEquipment1Productiond.setText(cyPlatformBean.getEquipment1Productiond());
        tvEquipment1DeliveryTime.setText(cyPlatformBean.getEquipment1DeliveryTime());

        tvEquipment2.setText(cyPlatformBean.getEquipment2());
        tvEquipment2Number.setText(cyPlatformBean.getEquipment2Number());
        tvEquipment2Model.setText(cyPlatformBean.getEquipment2Model());
        tvEquipment2Size.setText(cyPlatformBean.getEquipment2Size());
        tvEquipment2Demand.setText(cyPlatformBean.getEquipment2Demand());
        tvEquipment2Shipped.setText(cyPlatformBean.getEquipment2Shipped());
        tvEquipment2Delivered.setText(cyPlatformBean.getEquipment2Delivered());
        tvEquipment2Productiond.setText(cyPlatformBean.getEquipment2Productiond());
        tvEquipment2DeliveryTime.setText(cyPlatformBean.getEquipment2DeliveryTime());


        tvEquipment3.setText(cyPlatformBean.getEquipment3());
        tvEquipment3Number.setText(cyPlatformBean.getEquipment3Number());
        tvEquipment3Model.setText(cyPlatformBean.getEquipment3Model());
        tvEquipment3Size.setText(cyPlatformBean.getEquipment3Size());
        tvEquipment3Demand.setText(cyPlatformBean.getEquipment3Demand());
        tvEquipment3Shipped.setText(cyPlatformBean.getEquipment3Shipped());
        tvEquipment3Delivered.setText(cyPlatformBean.getEquipment3Delivered());
        tvEquipment3Productiond.setText(cyPlatformBean.getEquipment3Productiond());
        tvEquipment3DeliveryTime.setText(cyPlatformBean.getEquipment3DeliveryTime());


        tvShipmentRate2.setText(cyPlatformBean.getShipmentRate2());

        tvEquipment4.setText(cyPlatformBean.getEquipment4());
        tvEquipment4Number.setText(cyPlatformBean.getEquipment4Number());
        tvEquipment4Model.setText(cyPlatformBean.getEquipment4Model());
        tvEquipment4Size.setText(cyPlatformBean.getEquipment4Size());
        tvEquipment4Demand.setText(cyPlatformBean.getEquipment4Demand());
        tvEquipment4Shipped.setText(cyPlatformBean.getEquipment4Shipped());
        tvEquipment4Delivered.setText(cyPlatformBean.getEquipment4Delivered());
        tvEquipment4Productiond.setText(cyPlatformBean.getEquipment4Productiond());
        tvEquipment4DeliveryTime.setText(cyPlatformBean.getEquipment4DeliveryTime());

        tvEquipment5.setText(cyPlatformBean.getEquipment5());
        tvEquipment5Number.setText(cyPlatformBean.getEquipment5Number());
        tvEquipment5Model.setText(cyPlatformBean.getEquipment5Model());
        tvEquipment5Size.setText(cyPlatformBean.getEquipment5Size());
        tvEquipment5Demand.setText(cyPlatformBean.getEquipment5Demand());
        tvEquipment5Shipped.setText(cyPlatformBean.getEquipment5Shipped());
        tvEquipment5Delivered.setText(cyPlatformBean.getEquipment5Delivered());
        tvEquipment5Productiond.setText(cyPlatformBean.getEquipment5Productiond());
        tvEquipment5DeliveryTime.setText(cyPlatformBean.getEquipment5DeliveryTime());


        tvEquipment6.setText(cyPlatformBean.getEquipment6());
        tvEquipment6Number.setText(cyPlatformBean.getEquipment6Number());
        tvEquipment6Model.setText(cyPlatformBean.getEquipment6Model());
        tvEquipment6Size.setText(cyPlatformBean.getEquipment6Size());
        tvEquipment6Demand.setText(cyPlatformBean.getEquipment6Demand());
        tvEquipment6Shipped.setText(cyPlatformBean.getEquipment6Shipped());
        tvEquipment6Delivered.setText(cyPlatformBean.getEquipment6Delivered());
        tvEquipment6Productiond.setText(cyPlatformBean.getEquipment6Productiond());
        tvEquipment6DeliveryTime.setText(cyPlatformBean.getEquipment6DeliveryTime());

        lineAdapter.setNewData(cyPlatformBean.getLineBeans());
        gradientRoundProgress1.setProgress(cyPlatformBean.getRate1());
        gradientRoundProgress2.setProgress(cyPlatformBean.getRate2());
        gradientRoundProgress3.setProgress(cyPlatformBean.getRate3());
        gradientRoundProgress4.setProgress(cyPlatformBean.getRate4());
        lineView.setData(cyPlatformBean.getxValues(), cyPlatformBean.getyValues());
        hvChart.updateValueData(cyPlatformBean.getDatas(), cyPlatformBean.getxList(), cyPlatformBean.getyList());
    }


    private CYPlatformBean allInitDate() {
        CYPlatformBean cyPlatformBean = new CYPlatformBean();
        cyPlatformBean.setDate(sdf.format(new Date()));
        cyPlatformBean.setCapacity(1000);
        cyPlatformBean.setYield1("良率95%");
        cyPlatformBean.setYield2("良率95%");
        cyPlatformBean.setYield3("良率95%");
        cyPlatformBean.setYield4("良率95%");


        cyPlatformBean.setShipmentRate1("平均出货率：97%");

        cyPlatformBean.setEquipment1("打印设备1");
        cyPlatformBean.setEquipment1Number("订单编号：201907150002");
        cyPlatformBean.setEquipment1Model("型号：XTM-30B-E1012-T850");
        cyPlatformBean.setEquipment1Size("尺寸：1285*700");
        cyPlatformBean.setEquipment1Demand("需求：400套");
        cyPlatformBean.setEquipment1Shipped("待发货：0套");
        cyPlatformBean.setEquipment1Delivered("已交付：0套");
        cyPlatformBean.setEquipment1Productiond("需生产：400套");
        cyPlatformBean.setEquipment1DeliveryTime("交期：2019-07-16");

        cyPlatformBean.setEquipment2("打印设备2");
        cyPlatformBean.setEquipment2Number("订单编号：201907150002");
        cyPlatformBean.setEquipment2Model("型号：XTM-30B-E1012-T850");
        cyPlatformBean.setEquipment2Size("尺寸：1285*700");
        cyPlatformBean.setEquipment2Demand("需求：400套");
        cyPlatformBean.setEquipment2Shipped("待发货：0套");
        cyPlatformBean.setEquipment2Delivered("已交付：0套");
        cyPlatformBean.setEquipment2Productiond("需生产：400套");
        cyPlatformBean.setEquipment2DeliveryTime("交期：2019-07-16");

        cyPlatformBean.setEquipment3("贴合设备");
        cyPlatformBean.setEquipment3Number("订单编号：201907150002");
        cyPlatformBean.setEquipment3Model("型号：XTM-30B-E1012-T850");
        cyPlatformBean.setEquipment3Size("尺寸：1285*700");
        cyPlatformBean.setEquipment3Demand("需求：400套");
        cyPlatformBean.setEquipment3Shipped("待发货：0套");
        cyPlatformBean.setEquipment3Delivered("已交付：0套");
        cyPlatformBean.setEquipment3Productiond("需生产：400套");
        cyPlatformBean.setEquipment3DeliveryTime("交期：2019-07-16");

        cyPlatformBean.setShipmentRate2("平均出货率：97%");

        cyPlatformBean.setEquipment4("焊接设备1");
        cyPlatformBean.setEquipment4Number("订单编号：201907150002");
        cyPlatformBean.setEquipment4Model("型号：XTM-30B-E1012-T850");
        cyPlatformBean.setEquipment4Size("尺寸：1285*700");
        cyPlatformBean.setEquipment4Demand("需求：400套");
        cyPlatformBean.setEquipment4Shipped("待发货：0套");
        cyPlatformBean.setEquipment4Delivered("已交付：0套");
        cyPlatformBean.setEquipment4Productiond("需生产：400套");
        cyPlatformBean.setEquipment4DeliveryTime("交期：2019-07-16");

        cyPlatformBean.setEquipment5("焊接设备2");
        cyPlatformBean.setEquipment5Number("订单编号：201907150002");
        cyPlatformBean.setEquipment5Model("型号：XTM-30B-E1012-T850");
        cyPlatformBean.setEquipment5Size("尺寸：1285*700");
        cyPlatformBean.setEquipment5Demand("需求：400套");
        cyPlatformBean.setEquipment5Shipped("待发货：0套");
        cyPlatformBean.setEquipment5Delivered("已交付：0套");
        cyPlatformBean.setEquipment5Productiond("需生产：400套");
        cyPlatformBean.setEquipment5DeliveryTime("交期：2019-07-16");

        cyPlatformBean.setEquipment6("包装车间");
        cyPlatformBean.setEquipment6Number("订单编号：201907150002");
        cyPlatformBean.setEquipment6Model("型号：XTM-30B-E1012-T850");
        cyPlatformBean.setEquipment6Size("尺寸：1285*700");
        cyPlatformBean.setEquipment6Demand("需求：400套");
        cyPlatformBean.setEquipment6Shipped("待发货：0套");
        cyPlatformBean.setEquipment6Delivered("已交付：0套");
        cyPlatformBean.setEquipment6Productiond("需生产：400套");
        cyPlatformBean.setEquipment6DeliveryTime("交期：2019-07-16");

        List<CYPlatformBean.LineBean> lineData = new ArrayList<>();
        for (int i = 0; i < 4; i++) {
            CYPlatformBean.LineBean lineBean = new CYPlatformBean.LineBean();
            lineBean.setLineName("LINE1");
            lineBean.setDevideNum("11台");
            lineBean.setShipped("145");
            lineBean.setHasShipped("45");
            lineBean.setGoodsNum("330");
            lineBean.setNoGoodsNum("20");
            lineBean.setScrapNum("2");
            lineBean.setGoodsRate("88.50%");
            lineBean.setDate("2019-07-12");
            lineBean.setTotalOutput("350");
            lineData.add(lineBean);
        }
        cyPlatformBean.setLineBeans(lineData);

        cyPlatformBean.setRate1(96);
        cyPlatformBean.setRate2(83);
        cyPlatformBean.setRate3(5);
        cyPlatformBean.setRate4(61);


        List<String> xValues = new ArrayList<>();   //x轴数据集合
        List<Float> yValues = new ArrayList<>();  //y轴数据集合
        xValues.add("1月");
        xValues.add("2月");
        xValues.add("3月");
        xValues.add("4月");
        xValues.add("5月");
        xValues.add("6月");
        xValues.add("7月");
        xValues.add("8月");
        xValues.add("9月");
        xValues.add("10月");
        xValues.add("11月");
        xValues.add("12月");
        yValues.add(5f);
        yValues.add(14f);
        yValues.add(8f);
        yValues.add(12f);
        yValues.add(7f);
        yValues.add(17f);
        yValues.add(13f);
        yValues.add(20f);
        yValues.add(30f);
        yValues.add(35f);
        yValues.add(16f);
        yValues.add(20f);

        cyPlatformBean.setxValues(xValues);
        cyPlatformBean.setyValues(yValues);

        List<Integer> datas = new ArrayList<>();
        List<String> xList = new ArrayList<>();
        List<Integer> yList = new ArrayList<>();
        for (int i = 1; i < 32; i++) {
            if (i % 5 == 0) {
                xList.add(i + "日");
            } else {
                xList.add("");
            }
            datas.add(new Random().nextInt(300));
        }
        //根据数据的最大值生成上下对应的Y轴坐标范围
        Integer maxYAxis = getMaxValue(datas);
        Integer minYAxis = getMinValue(datas);
        Integer keduSpace = ((int) ((maxYAxis - minYAxis) * 1.15f)) / 6;
        for (int j = 0; j < 7; j++) {
            yList.add(keduSpace * j);
        }
        cyPlatformBean.setDatas(datas);
        cyPlatformBean.setxList(xList);
        cyPlatformBean.setyList(yList);
        return cyPlatformBean;
    }
}
